<template>
  <div class="layoutlist">
    <el-form ref="form" :model="form" label-position="top" class="myform">
      <el-form-item label="成品加工单编码" class="myform-item">
        <div style="display: flex">
          <el-input
            v-model="form.processing_code"
            placeholder="请输入成品加工单"
            @keyup.enter.native="onSearch"
            clearable
            style="width: 400px; margin-right: 20px"
          ></el-input>
          <el-button type="primary" size="default" @click="onSearch"
            >查询</el-button
          >
        </div>
      </el-form-item>
    </el-form>

    <el-table :data="tableData" border stripe style="margin-top: 10px">
      <el-table-column
        prop="processing_code"
        label="成品加工单编码"
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop="type_no"
        label="款号"
        align="center"
      >
      </el-table-column>
      
      <el-table-column label="操作" align="center">
        <template slot-scope="{ row }">
          <el-button
            type="text"
            size="default"
            @click="onNoQC(row.processing_code)"
            >免QC质检</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <pagination
      :form="form"
      :total="total"
      @paginationPostOrderTaskList="postGetprocessing_list"
    />
  </div>
</template>

<script>
import { postGetprocessing_list, postAdminCodeSetQcPass } from "@/api";
import pagination from "@/components/pagination.vue";
export default {
  components: {
    pagination,
  },
  data() {
    return {
      loading: false,
      total: 0,
      form: {
        processing_code: "",
        page: 1,
        size: 10,
      },
      tableData: [],
    };
  },
  activated() {
    let form = this.form;
    this.postGetprocessing_list(form);
  },
  methods: {
    // 免qc检查
    onNoQC(processing_code) {
      console.log("免qc检查");
      let that = this;
      let obj = {
        processing_code,
      };
      this.$confirm(`此操作未不可逆操作！${processing_code} 确定免QC质检`, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          postAdminCodeSetQcPass(obj).then((res) => {
            that.$message({
              type: "success",
              message: "操作成功!",
            });
            let form = this.form;
            that.postCodegetPocessinglist(form);
            that.dialogTableVisibleQCMian = false;
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },

    // 加工单列表
    postGetprocessing_list(form) {
      this.form = form;
      postGetprocessing_list(form).then((res) => {
        console.log("加工单列表", res);
        this.tableData = res.data;
        this.total = res.total;
      });
    },
    // 查询
    onSearch() {
      let form = this.form;
      this.postGetprocessing_list(form);
    },
  },
};
</script>

<style lang="scss" scoped>
.layoutlist {
  @include global-back;
}
</style>